package ins.wink.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import ins.wink.entity.History;
import ins.wink.service.HistoryService;

/**
 * 历史记录controlle层
 */

@Controller
public class HistoryController {
	//注入service层
	@Autowired
	private HistoryService historyService;
	
	//历史记录
	@RequestMapping("/historyAction_toHistory")
	public String historyAction_toHistory(HttpServletRequest request,Model model) {
		//查询历史记录
		List<History> listhistory = historyService.listHistorys();
		request.getSession().getAttribute("user");
		model.addAttribute("listhistory", listhistory);
		return "WEB-INF/his/his";
	}
	////简记码模糊查询
	@RequestMapping(value="/goodsAction_searchUI2",method=RequestMethod.GET)
	public String goodsAction_findGoodsByNm(History history,Model model) {
		//获取简记码
		String nm = history.getNm();
		//获取名称
		String goodname = history.getGoodname();
		//获取仓库编号
		String storeid = history.getStoreid();
		System.out.println(nm);
		System.out.println(goodname);
		System.out.println(storeid);
		//执行查询操作
		List<History> list = historyService.historyLikeNms(nm, goodname, storeid);
		//数据回显页面上
		model.addAttribute("listhistory",list);
		model.addAttribute("nm",nm);
		model.addAttribute("goodname",goodname);
		model.addAttribute("storeid",storeid);
		return "WEB-INF/his/his";
	}
}
